using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class DoctorHuRelMap : EntityTypeConfiguration<DoctorHuRel>
	{
		public DoctorHuRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("DoctorHuRels");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.DoctorId).HasColumnName("DoctorId");
			this.Property(t => t.HospitalUnitId).HasColumnName("HospitalUnitId");

			// Relationships
			this.HasOptional(t => t.Doctor)
				.WithMany(t => t.DoctorHuRels)
				.HasForeignKey(d => d.DoctorId);
				
			this.HasOptional(t => t.RefHu)
				.WithMany(t => t.DoctorHuRels)
				.HasForeignKey(d => d.HospitalUnitId);
				
		}
	}
}

